@section('lunbo')

<div class="mainSlide" id="mainSlide">
	 <div id="topslide">
	 @foreach($lunbos as $k=>$v)
	      <div @if($v->aid == $data['aid']) class="cell cur" @else class="cell" @endif ><div class="prom" style="background-image:url({{$v->apic}});"></div><div class="w1200"> <a href="http://www.okbuy.com/topic/show/53270" target="_blank" class="promLink"></a></div></div>
	  @endforeach    
	      <div class="w1200 pgWidth">
	      <span class="slideNum" id="slideNum">
	    	@foreach($lunbos as $k=>$v)  
	    	<i @if($v->aid == $data['aid']) class="cur" @else class="" @endif></i>
			@endforeach
	     </span></div>
	  </div>
	  <img src="{{asset('/HomeCss/picture/8279506eec1b47bc61c04ed0532cfcba.png')}}" class="ad">
	  <a class="btn btn_l">&lt;</a>
	  <a class="btn btn_r">&gt;</a>
	</div>
@endsection
@section('js')
<script type="text/javascript">
	<!-- 轮播图 -->
	//全局变量
	var w = 0;
	//获取图片个数
	var length = $('#topslide .cell').length;
	//左右按钮绑定单击事件
	$('#mainSlide .btn_r').click(function(){
		moveR();
	})
	$('#mainSlide .btn_l').click(function(){
		moveL();
	})
	//启动定时器
	var inte = setInterval(moveR,3000);
	//鼠标悬停
	$('#mainSlide').hover(function(){
		//鼠标移入
		clearInterval(inte);
		inte = null;
	},function(){
		inte = setInterval(moveR,3000);
	})
	//封装向右移动操作
	function moveR()
	{
		w++;
		// console.log(i);
		//越界[判断
		if(w == length){
			$('#topslide .cell').first().attr('class','cell cur').fadeIn(1000);
			$('#topslide .cell').last().attr('class','cell').fadeIn(1000);
			w = 0;
		}else{
			//设置样式
			$('#topslide .cell').eq(w).attr('class','cell cur');
			$('#topslide .cell').eq(w-1).attr('class','cell');
		}
		if(w == length){
			$('#topslide .slideNum i').eq(0).addClass('cur').siblings().removeClass('cur');
		}else{
			//设置圆点移动
			$('#topslide .slideNum i').eq(w).addClass('cur').siblings().removeClass('cur');
		}
	}
	function moveL()
	{
		w--;
		//越界[判断
		if(w == -1){
			$('#topslide .cell').last().attr('class','cell cur');
			$('#topslide .cell').first().attr('class','cell');
			w = length-1;
		}else{
			$('#topslide .cell').eq(w).attr('class','cell cur');
			$('#topslide .cell').eq(w+1).attr('class','cell');
		}
		//设置圆点移动
		$('#topslide .slideNum i').eq(w).addClass('cur').siblings().removeClass('cur');
	}
	//给小圆点绑定单击事件
	$('#topslide .slideNum i').click(function(){
		//获取当前对象索引
		w = $(this).index();
		$('#topslide .cell').each(function(){
			$(this).attr('class','cell');
		});
		//设置样式
		$('#topslide .cell').eq(w).attr('class','cell cur');
		//设置圆点移动
		$('#topslide .slideNum i').eq(w).addClass('cur').siblings().removeClass('cur');
	})
	//给小圆点绑定移入事件
	$('#topslide .slideNum i').mouseover(function(){
		//获取当前对象索引
		w = $(this).index();
		$('#topslide .cell').each(function(){
			$(this).attr('class','cell');
		});
		//设置样式
		$('#topslide .cell').eq(w).attr('class','cell cur');
		//设置圆点移动
		$('#topslide .slideNum i').eq(w).addClass('cur').siblings().removeClass('cur');
	})

</script>
@endsection